package com.triz.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.triz.common.annotation.Log;
import com.triz.common.core.controller.BaseController;
import com.triz.common.core.domain.AjaxResult;
import com.triz.common.enums.BusinessType;
import com.triz.business.domain.FunctionalModel;
import com.triz.business.service.IFunctionalModelService;
import com.triz.common.utils.poi.ExcelUtil;
import com.triz.common.core.page.TableDataInfo;

/**
 * 功能建模Controller
 * 
 * @author hlk
 * @date 2025-11-15
 */
@RestController
@RequestMapping("/business/functionalModel")
public class FunctionalModelController extends BaseController
{
    @Autowired
    private IFunctionalModelService functionalModelService;

    /**
     * 查询功能建模列表
     */
    @GetMapping("/list")
    public TableDataInfo list(FunctionalModel functionalModel)
    {
        startPage();
        List<FunctionalModel> list = functionalModelService.selectFunctionalModelList(functionalModel);
        return getDataTable(list);
    }

    /**
     * 导出功能建模列表
     */
    @Log(title = "功能建模", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FunctionalModel functionalModel)
    {
        List<FunctionalModel> list = functionalModelService.selectFunctionalModelList(functionalModel);
        ExcelUtil<FunctionalModel> util = new ExcelUtil<FunctionalModel>(FunctionalModel.class);
        util.exportExcel(response, list, "功能建模数据");
    }

    /**
     * 获取功能建模详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(functionalModelService.selectFunctionalModelById(id));
    }

    /**
     * 新增功能建模
     */
    @Log(title = "功能建模", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FunctionalModel functionalModel)
    {
        return toAjax(functionalModelService.insertFunctionalModel(functionalModel));
    }

    /**
     * 修改功能建模
     */
    @Log(title = "功能建模", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FunctionalModel functionalModel)
    {
        return toAjax(functionalModelService.updateFunctionalModel(functionalModel));
    }

    /**
     * 删除功能建模
     */
    @Log(title = "功能建模", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(functionalModelService.deleteFunctionalModelByIds(ids));
    }







    /**
     * 功能缺陷
     */
    @GetMapping("/functionalModelFlawList")
    public TableDataInfo functionalModelFlawList(FunctionalModel functionalModel) {
        startPage();
        List<FunctionalModel> list = functionalModelService.selectfunctionalModelFlawList(functionalModel);
        return getDataTable(list);
    }



}
